"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.LocationHelper = void 0;
const Logger_1 = require("./Logger");
const MathUtils_1 = require("./MathUtils");
class LocationHelper {
    static getDistance(longitude1, latitude1, longitude2, latitude2) {
        let radLat1 = MathUtils_1.MathUtils.degreesToRadians(latitude1);
        let radLat2 = MathUtils_1.MathUtils.degreesToRadians(latitude2);
        let a = radLat1 - radLat2;
        let b = MathUtils_1.MathUtils.degreesToRadians(longitude1) - MathUtils_1.MathUtils.degreesToRadians(longitude2);
        let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
            Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
        s = s * 6378.137; // EARTH_RADIUS;
        s = Math.round(s * 10000) / 10000; //输出为公里
        Logger_1.Logger.log("getDistance=====", s);
        return Math.floor(s * 1000);
    }
    //"23.258702000001627,113.28866699999783"   "1,1"
    static JingWei2Distance(location1, location2) {
        let location1Arr = location1.split(",");
        if (location1Arr.length != 2) {
            return 0;
        }
        let location2Arr = location2.split(",");
        if (location2Arr.length != 2) {
            return 0;
        }
        let longitude1 = parseFloat(location1Arr[0]); //经度
        let latitude1 = parseFloat(location1Arr[1]); //纬度
        let longitude2 = parseFloat(location2Arr[0]); //经度
        let latitude2 = parseFloat(location2Arr[1]); //纬度
        let distance = this.getDistance(longitude1, latitude1, longitude2, latitude2);
        Logger_1.Logger.log("JingWei2Distance===", distance);
        return distance;
    }
}
exports.LocationHelper = LocationHelper;
